package com.l2j.test.common.exception;

import com.l2j.test.common.result.Result;
import com.l2j.test.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handle (Exception e)
    {
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(RemoveApartmentException.class)
    @ResponseBody
    public Result hanle (RemoveApartmentException e){
        e.printStackTrace();
        return Result.fail(ResultCodeEnum.DELETE_APARTMENT_INCLUDE_ROOM_ERROR);
    }
}
